package cn.anc.aonicardv.widget;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;

import androidx.appcompat.widget.AppCompatTextView;

public class SelectTextView extends AppCompatTextView {

    private boolean mIsSelected;
    private Paint mPaint;

    public SelectTextView(Context context) {
        this(context, null);
    }

    public SelectTextView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    private void init() {
        mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mPaint.setColor(0xFF33BBFF);
        mPaint.setStrokeWidth(10);
        mPaint.setStyle(Paint.Style.STROKE);
    }

    public void setSelected(boolean isSelect) {
        mIsSelected = isSelect;
        invalidate();
    }

    public void setSelectedColor(int color) {
        mPaint.setColor(color);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        if (mIsSelected) {
            canvas.drawRect(0,0,getWidth(),getHeight(),mPaint);
        }
    }
}
